package com.cjm.one.webmanager.service.system.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.model.base.BaseDeleteMoreVo;
import com.cjm.one.model.system.dto.SysRoleDto;
import com.cjm.one.model.system.entity.SysRole;
import com.cjm.one.model.system.vo.RoleDetailVO;
import com.cjm.one.system.client.SystemRoleClient;
import com.cjm.one.webmanager.service.system.SysRoleService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Slf4j
public class SysRoleServiceImpl implements SysRoleService {
    @Resource
    private SystemRoleClient systemRoleClient;
    //获取所有角色列表
    @Override
    public List<SysRole> getAllSysRoleList() {
        List<SysRole> data = systemRoleClient.list().getData();
        log.info("获取角色列表成功:{}",data);
        return data;
    }

    @Override
    public Page<SysRole> page(SysRoleDto sysRoleDto) {
        return  systemRoleClient.page(sysRoleDto).getData();
    }

    @Override
    public Boolean updateById(RoleDetailVO sysRole) {
        return systemRoleClient.update(sysRole).getData();

    }

    @Override
    public Boolean save(RoleDetailVO sysRole) {
        return systemRoleClient.addSysRole(sysRole).getData();

    }

    @Override
    public Boolean removeById(Long id) {

        return systemRoleClient.delete(id).getData();
    }

    @Override
    public SysRole getById(Long id) {
        return systemRoleClient.getById(id).getData();
    }

    @Override
    public BaseDeleteMoreVo removeByIds(List<Long> ids) {
        return systemRoleClient.deleteBatchIds(ids).getData();
    }

    @Override
    public Boolean updateStatus(SysRole sysRole) {
        return systemRoleClient.updateStatus(sysRole).getData();
    }

    @Override
    public RoleDetailVO getSysRoleDetail(Long id) {
        return systemRoleClient.getSysRoleDetail(id).getData();
    }
}
